import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
import Index from '@/pages/index' //首页
import home from '@/pages/Home' //首页
import banner from '@/pages/banner'
import classifyIndex from '@/pages/classifyIndex'
import hots from '@/pages/hots'
import classify from '@/pages/classify'
import mainCon from '@/pages/mainCon'
import shopping from '@/pages/shopping'
import user from '@/pages/user'
import login from '@/pages/login'

Vue.use(Router)
    /**
     * 重写路由的push方法
     */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
}
export default new Router({
    routes: [{
            path: '/',
            redirect: '/home'
        },
        {
            path: '/',
            name: '首页管理',
            component: Index,
            children: [{
                    path: "/home",
                    name: "首页统计",
                    component: home
                }, {
                    path: "/banner",
                    name: "轮播图管理",
                    component: banner
                },
                {
                    path: "/classifyIndex",
                    name: "首页分类管理",
                    component: classifyIndex
                },
                {
                    path: "/hots",
                    name: "热销商品",
                    component: hots
                },

            ]
        }, {
            path: '/',
            name: '分类管理',
            component: Index,
            children: [{
                path: "/mainCon",
                name: "分类管理",
                component: mainCon
            }]
        }, {
            path: '/',
            name: '商品管理',
            component: Index,
            children: [{
                path: "/classify",
                name: "商品管理",
                component: classify
            }]
        },
        {
            path: '/shopping',
            name: '购物车管理',
            component: shopping
        },
        {
            path: '/user',
            name: '用户管理',
            component: user
        },
        {
            path: '/login',
            name: '用户登录',
            component: login
        },
    ]
})

// export default new Router({
//     routes: [{
//             path: '/',
//             redirect: '/banner'
//         },
//         {
//             path: '/',
//             name: '首页管理',
//             component: Index,
//             children: [{
//                     path: "/banner",
//                     name: "轮播图管理",
//                     component: banner
//                 },
//                 {
//                     path: "/classifyIndex",
//                     name: "首页分类管理",
//                     component: classifyIndex
//                 },
//                 {
//                     path: "/hots",
//                     name: "热销商品",
//                     component: hots
//                 },

//             ]
//         }, {
//             path: "/mainCon",
//             name: "分类管理",
//             component: mainCon
//         }, {
//             path: "/classify",
//             name: "商品管理",
//             component: classify
//         },
//         {
//             path: '/shopping',
//             name: '购物车管理',
//             component: shopping
//         },
//         {
//             path: '/user',
//             name: '用户管理',
//             component: user
//         },
//     ]
// })